package org.example.tasks;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ScheduledTasks {
    // 每 5 秒执行一次
    @Scheduled(fixedRate = 5000)
    public void reportCurrentTime() {
        System.out.println("Current time: " + new Date());
    }

    // 使用 Cron 表达式（每天凌晨执行）
    @Scheduled(cron = "0 0 0 * * ?")
    public void dailyCleanup() {
        System.out.println("Performing daily cleanup...");
    }
}
